{% include "header.html"%}
<div class="container-fluid">
  <div class="row">
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
      <form method="post" id="form">
        <input type="hidden" name="taskid" value="{{task.ID}}">
        <div class="col-md-12">
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="name">任务名称</label>
              <p class="form-control-static">(只能是数字、字母、下划线；长度不超过50；不能修改)</p>
            </div>
            <input class="form-control" type="text" name="name" id="name" value="{{task.Name}}" readonly>
          </div>
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="desc">任务描述</label>
              <p class="form-control-static">(任务描述)</p>
            </div>
            <input class="form-control" type="text" name="desc" id="desc" value="{{task.Desc}}">
          </div>
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="apiurl">推送地址</label>
              <p class="form-control-static">(HTTP POST推送消息)</p>
            </div>
            <input class="form-control" type="text" name="apiurl" id="apiurl" value="{{task.Apiurl}}">
          </div>
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="apiurl">数据封装协议</label>
              <p class="form-control-static"><span id="pack-help" class="glyphicon glyphicon-question-sign help-btn"></span></p>
            </div>
            <div class="form-control-static">
              <input type="radio" name="packProtocal" value="0" id="packProtocal_default" {% if (task.PackProtocal|integer !=1 ) %} checked
                {%endif%}> 默认
              <input type="radio" name="packProtocal" value="1" id="packProtocal_eventcenter" {% if (task.PackProtocal|integer==1 ) %}
                checked {%endif%}> 消息中心推送协议
            </div>
          </div>
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="routineCount">推送消息并发数</label>
              <p class="form-control-static">(1-100)</p>
            </div>
            <input class="form-control" type="text" name="routineCount" id="routineCount" value="{{task.RoutineCount}}">
          </div>
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="reRoutineCount">重推消息并发数</label>
              <p class="form-control-static">(1-100)</p>
            </div>
            <input class="form-control" type="text" name="reRoutineCount" id="reRoutineCount" value="{{task.ReRoutineCount}}">
          </div>
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="reSendTime">重推时间间隔</label>
              <p class="form-control-static">(0-30000ms)</p>
            </div>
            <input class="form-control" type="text" name="reSendTime" id="reSendTime" value="{{task.ReSendTime}}">
          </div>
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="retryCount">重推消息次数</label>
              <p class="form-control-static">(0-10)</p>
            </div>
            <input class="form-control" type="text" name="retryCount" id="retryCount" value="{{task.RetryCount}}">
          </div>
          <div class="form-group col-md-6">
            <div class="form-inline">
              <label for="timeout">推送消息超时</label>
              <p class="form-control-static">(1-30000ms)</p>
            </div>
            <input class="form-control" type="text" name="timeout" id="timeout" value="{{task.Timeout}}">
          </div>
          <div class="form-group col-md-6">
						<div class="form-inline">
							<label for="alert">消息报警</label>
							<p class="form-control-static">(消息推送失败超过一定次数或频率时将发送失败信息,使用分号`;`隔开)</p>
              <div class="radio">
								<label>
                    <input type="radio" name="alert" id="alert" value="1" {% if task.Alert== 1 %}checked{% endif %}> 开启
                </label>
								<label>
                    <input type="radio" name="alert" id="alert" value="0" {% if task.Alert==0 %}checked {%endif%}> 关闭
                </label>
							</div>
						</div>
						电话：<input class="form-control" type="text" name="phoneNumbers" id="phoneNumbers" value="{{task.PhoneNumbers}}"  placeholder="number1;number2">
            邮箱：<input class="form-control" type="text" name="emails" id="emails" value="{{task.Emails}}"  placeholder="email1;email2">
					</div>
          <div class="col-md-6">
            <div class="form-group col-md-12">
              <div class="form-inline col-md-12">
                <!-- <label for="state">审核人</label>
                <div class="select">
                  <select name="auditUser" id="auditUser" class="form-control">
                    <option value=""></option>
                    {% for auditUser in auditUsers %}
                    <option value="{{auditUser.Username}}">{{auditUser.Username}}</option>
                    {% endfor %}
                  </select> -->
                <div class="select">
                  <button type="button" class="btn btn-primary" id="updateTaskBtn" onclick="modifyTask()">更新任务</button>
                  <button type="button" class="btn btn-info" id="updateTaskFieldsBtn" onclick="modifyTaskFields()">更新订阅</button>
                </div>
              </div>
            </div>
            <div class="form-group">            
              <div class="form-inline col-md-6">
                  <label>自定义分组</label>
                  <a href="javascript:void(0)" onclick="addCategory(this)" title="新增分组" class="glyphicon glyphicon-plus"></a>																						
                  <select class="form-control" id="category_select" name="category">
                    {%for category in categories %}
                      <option value="{{category}}" {%if category == task.Category%} selected {%endif%}>{{category}}</option>
                    {%endfor%}
                  </select>
              </div>
            </div>
          </div>
        </div>
        <div id="rightdiv" class="form-inline">
          <div class="col-md-12">
						<label for="apiurl">正则表达式</label>
						<p class="form-control-static"><span id="regexp-help" class="glyphicon glyphicon-question-sign help-btn"></span></p>
					</div>
          {% for schema, tables in taskColumnsMap %} {% for table, fields in tables %}
          <div class="col-md-12 right-field-div" id="{{schema}}-{{table}}">
            <h3><input class="form-control input-lg schema-name" onchange="changeFieldValue(this)" value="{{schema}}"></input>
            <input class="form-control input-lg table-name" onchange="changeFieldValue(this)" value="{{table}}"></input>
              <a href="javascript:void(0)" onclick="removeFieldDiv(this)" class="btn btn-lg">
                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
              </a>
            </h3>
            <div class="row rowCont">
              {% for f in fields %}
              <div class="col-md-4" style="margin-bottom:5px;">
                <div class="form-group">
                  <div class="input-group">
                    <input value="{{f.Column}}" readonly type="text" class="form-control">
                    <input name="fields" value="{{schema}}@@{{table}}@@{{f.Column}}" type="hidden">
                  </div>
                  <div class="checkbox"><label><input type="checkbox" name="{{schema}}@@{{table}}@@{{f.Column}}" value="1" {%if f.Send%}checked{%endif%}></input>是否推送值<label>
                </div>
                <a href="#" onclick="removeField(this)"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
              </div>
            </div>
            {% endfor %}
            </div>
          </div> 
        {% endfor %} 
        {% endfor%}
        </div>
      </form>
      <div class="col-sm-3 col-md-2 sidebar" id="add-left-sidebar">
        {% include "taskleft.html" %}
      </div>
    </div>
  </div>

  {% include "footer.html"%}
